package com.xiaoyu.lanling.feature.charming

import `in`.srain.cube.request.JsonData
import com.xiaoyu.base.app.AppContext
import com.xiaoyu.base.data.UserData
import com.xiaoyu.base.model.User
import com.xiaoyu.base.utils.extensions.dp
import com.xiaoyu.lanling.R
import com.xiaoyu.lanling.media.image.ImageLoadParam
import com.xiaoyu.lanling.media.image.UserImageLoadParam
import java.io.Serializable

class CharmingLevel(val jsonData: JsonData) : Serializable {
    val user = User.fromJson(jsonData.optJson("user"))
    val info = jsonData.optJson("charmingLevelUpInfo")
    val num = info.optString("value")
    val level = info.optInt("level")
    val levelIcon = info.optString("icon")
    val message = info.optString("message")
    val avatarLoadParam = UserImageLoadParam.newBuilder()
            .setUserAndDP(UserData.getInstance().user, 96)
            .setRounded(true)
            ?.setRoundingBorderColor(AppContext.getColor(R.color.colorWhite))
            ?.setRoundingBorderWidth(1.dp.toInt())
            ?.build()
    val levelIconLoadparam = ImageLoadParam
            .newBuilder()
            .setWidth(80.dp.toInt())
            .setHeight(24.dp.toInt())
            .setUrl(levelIcon)
            .build()
}